package com.system.controller;

import com.system.pojo.AssessmentClassification;
import com.system.service.AssessmentClassificationService;
import com.system.util.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class AssessmentClassificationController {
    @Autowired
    private AssessmentClassificationService assessmentClassificationService;
    JSONUtil jsonUtil = new JSONUtil();
    @RequestMapping("selectAllAssessmentClassification")
    @ResponseBody
    public String selectAllAssessmentClassification(){
        List<AssessmentClassification> list = assessmentClassificationService.select(null);
        return jsonUtil.toJson("1", list, "");
    }

    @RequestMapping("selectMenuTree")
    @ResponseBody
    public String selectMenuTree(String roleid) {
        return assessmentClassificationService.selectMenuTree(roleid);
    }

    @RequestMapping("selectAllMenus")
    @ResponseBody
    public String selectAllMenus() {
        return assessmentClassificationService.selectAllMenus();
    }

    @RequestMapping("selectSubMenus")
    @ResponseBody
    public String selectSubMenus(String id) {
        return assessmentClassificationService.selectSubMenus(id);
    }

    @RequestMapping("updateMenuName")
    @ResponseBody
    public String updateMenuName(@RequestBody List<AssessmentClassification> assessmentClassifications) {
        return assessmentClassificationService.update(assessmentClassifications.get(0));
    }

    @RequestMapping("turnOn")
    @ResponseBody
    public String turnOn(String id) {
        return assessmentClassificationService.turnOn(id);
    }

    @RequestMapping("turnOff")
    @ResponseBody
    public String turnOff(String id) {
        return assessmentClassificationService.turnOff(id);
    }

    @RequestMapping("saveMenu")
    @ResponseBody
    public String saveMenu(@RequestBody List<AssessmentClassification> assessmentClassifications) {
        return assessmentClassificationService.insert(assessmentClassifications.get(0));
    }

//    public AssessmentClassificationService getAssessmentClassificationService() {
//        return assessmentClassificationService;
//    }
//
//    public void setAssessmentClassificationService(AssessmentClassificationService assessmentClassificationService) {
//        this.assessmentClassificationService = assessmentClassificationService;
//    }
}
